package cz.muni.fi.pv168.confusinglibrary.libs;

import java.util.List;

/**
 * AuthorManager manages authors.
 *
 * @author Riema
 */
public interface AuthorManager {

    /**
     * This adds Author to a group of already existing Authors.
     * It's expected that author doesn't already exist in group - ie. id is  null.
     *
     * @param author Author to be added, cannot be null, author's id is supposed to be null
     * @return Author after adding, ie. with proper id
     * @throws NullPointerException if parametr is null
     * @throws IllegalArgumentException if author has id (!= null)
     */
    Author addAuthor(Author author);

    /**
     * This removes Author from a group of existing Authors.
     * And sets null as id of removed Author.
     *
     * @param author Author to be removed, cannot be null
     * @throws NullPointerException if paramter is null
     * @throws IllegalArgumentException if author isn't in group or has null id
     */
    void removeAuthor(Author author);

    /**
     * This updates information about Author.
     * Author is supposed to in group,
     * attributes can be changed all except id
     *
     * @param author Author with fixed id, and with updated information, cannot be null
     * @return  Author after updating
     * @throws NullPointerException if parametr is null
     * @throws IllegalArgumentException if author with this id isn't in group or id is null
     */
    void updateAuthor(Author author);

    /**
     *
     * @return List of all Authors, if there is no Author returns empty List
     */
    List<Author> getAllAuthors();

    /**
     *
     * @param id we're looking for author having such id
     * @return Author with this id or null if there isn't such author
     * @throws NullPointerException if parametr is null
     */
    Author findAuthorById(Long id);

    /**
     * All Authors with given surname
     *
     * @param surname parametr for searching - cannot be null
     * @return List of all Authors with this surname (can be empty)
     * @throws NullPointerException if parametr is null
     */
    List<Author> findAuthorsByName(String surname);

    /**
     * All Authors with given surname and name
     *
     * @param surname parametr for searching - cannot be null
     * @param name option parametr for searching
     * @return List of all Authors with this surname and name (can be empty)
     * @throws NullPointerException if first parametr (surname) is null
     */
    List<Author> findAuthorsByName(String surname, String name);
}
